package com.hl.util.KL.Encryption.ECC;

import java.math.BigInteger;
import java.nio.charset.Charset;
import android.util.Base64;

class StringExtend {
	BigInteger Base256ToBigIntger(String str256) {
		byte[] tmpByte = new byte[str256.length()];
		for (int i = 0; i < tmpByte.length; ++i) {
			tmpByte[i] = (byte) str256.charAt(i);
		}
		return new BigInteger(tmpByte);
	}

	BigInteger ByteToBigInteger(String byteString) {
		String bString = "00000000".substring(0, 8 - byteString.length() % 8)
				+ byteString;
		byte[] bt = new byte[bString.length() / 8];
		for (int i = bt.length - 1; i >= 0; --i) {
			bt[i] = (byte) Integer.parseInt(
					bString.substring(i * 8, i * 8 + 8), 2);
		}
		return new BigInteger(bt);
	}

	String EncodeBase64String(String str) {
		return Base64.encodeToString(str.getBytes(Charset.forName("UTF-8")), Base64.NO_WRAP);
	}

	String DecodeBase64String(String str) {
		byte[] bytes = Base64.decode(str, Base64.NO_WRAP);
		return new String(bytes, Charset.forName("UTF-8"));
	}
}
